package com.wzf.greattruth.jvm.vola;

public class Singleton {
    private static volatile Singleton instance;

    private Singleton() {
        super();
    }

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (Singleton.class) {
                // 如果在等待synchronized结束前已经有线程创建Instance则直接忽略。
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}
